home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / MMmalloc / MMinstall < prev    next >
Encoding:
Text File  |  1994-08-02  |  2.2 KB  |  102 lines

  1. #!/bin/tcsh
  2.  
  3. #
  4. # MMinstall - install MMmalloc library
  5. #                        Gianni Mariani 9-Apr-1994
  6. #
  7. #
  8.  
  9. echo "MMmalloc install proceedure"
  10.  
  11. set MMLIBNAM = libmalloc.so
  12. set MMLIB = $MMLIBNAM
  13. set THELIB = /lib/libmalloc.so
  14. set ORIGLIB = /lib/libmalloc.so.orig
  15. set ARMFILE = /var/malloc/ArmMMmalloc
  16.  
  17. if ( ! -w /lib ) then
  18.     echo "You must be root to run $0"
  19.     exit 1
  20. endif
  21.  
  22. if ( ! -f $THELIB && ! -f $ORIGLIB ) then
  23.     echo "Cannot find $THELIB : Aborting"
  24.     exit 1
  25. endif
  26.  
  27.  
  28. # lets go and find the MMmalloc library
  29. if ( ! -f $MMLIB ) then
  30.     set MMLIB = ${0:h}/$MMLIBNAM
  31.     if ( ! -f $MMLIB ) then
  32.     echo "Cannot find MMmalloc library"
  33.     exit 1
  34.     endif
  35. else
  36.     # make sure we are damn sure that this is not being run
  37.     # in /lib
  38.     if ( $cwd == /lib ) then
  39.     set MMLIB = ${0:h}/$MMLIBNAM
  40.     if ( ! -f $MMLIB ) then
  41.         echo "Cannot find MMmalloc library"
  42.         exit 1
  43.     endif
  44.     endif
  45. endif
  46.  
  47. # make sure that the original library is saved
  48. if ( ! -f $ORIGLIB ) then
  49.     if ( -f $THELIB ) then
  50.     ln $THELIB $ORIGLIB
  51.     echo "== Linking the original malloc library for posterity"
  52.     echo "    $THELIB ----> $ORIGLIB"
  53.     endif
  54. else
  55.     echo "== Original malloc library exists and remains unscathed"
  56.     echo "    $ORIGLIB"
  57. endif
  58.  
  59. echo "== To uninstall MMmalloc simply move"
  60. echo "    $ORIGLIB ----> $THELIB"
  61. echo "== using the command below"
  62. echo ""
  63. echo "    /bin/mv $ORIGLIB $THELIB"
  64. echo ""
  65.     
  66.  
  67. if ( ! -f $ARMFILE ) then
  68.     if ( ! -d ${ARMFILE:h} ) then
  69.     mkdir -p ${ARMFILE:h}
  70.     chmod 755 ${ARMFILE:h}
  71.     chown root.sys ${ARMFILE:h}
  72.     touch $ARMFILE
  73.     chmod 644 ${ARMFILE}
  74.     chown root.sys ${ARMFILE}
  75.     echo "== Recycle has been enabled by creating :"
  76.     echo "   ${ARMFILE}"
  77.     echo "== Disable recycle by removing ${ARMFILE}"
  78.     else
  79.     echo "== Recycle is disabled with this file missing"
  80.     echo "   ${ARMFILE}"
  81.     echo "== See MMmalloc README for more details"
  82.     endif
  83. else
  84.     echo "== Recycle is enabled - arm file exists"
  85.     echo "   ${ARMFILE}"
  86. endif
  87. echo ""
  88.     
  89. # copy the MMmalloc library to /lib doing some fancy footwork
  90. # to make sure processes already using /lib/libmalloc.so don't
  91. # have their executable ripped out from underneath them.
  92.  
  93. /bin/cp $MMLIB ${THELIB}.tmp
  94. chmod 444 ${THELIB}.tmp
  95. chown root.sys ${THELIB}.tmp
  96. /bin/mv ${THELIB}.tmp ${THELIB}
  97.  
  98. echo "**** MMmalloc installed ****"
  99.  
  100. exit 0
  101.  
  102.